package com.own.core.util;



import java.util.regex.Pattern;

import org.apache.wicket.validation.validator.AbstractValidator;
import org.apache.wicket.validation.validator.PatternValidator;

import com.own.core.html.form.validateType;

public class OwnPatternValidator extends PatternValidator {

	public static String ARABIC_NUMBERIC = "\u0660\u0661\u0662\u0663\u0664\u0665\u0666\u0667\u0668\u0669";
	public static String ARABIC_CHARACTER = "\u0621-\u064A";

	public static String PASSWORD_PATTERN = "[A-Za-z0-9-_$%#@!\\s]*";
	public static String NUMBERIC_PATTERN = "[0-9]*";
	public static String ALPHA_PATTERN = "[A-Za-z\\s" + ARABIC_CHARACTER + "-_\\.]*";
	public static String ALPHA_NUMBERIC_PATTERN = "[A-Za-z0-9-_\\s"
			+ ARABIC_CHARACTER + "-_\\.]*";
	public static String EMAIL_PATTERN = "^[_A-Za-z0-9-]+(\\.[_A-Za-z0-9-]+)*@[A-Za-z0-9-]+(\\.[A-Za-z0-9-]+)*((\\.[A-Za-z]{2,}){1}$)";

	public static String CLASS_PATTERN = "[A-Za-z0-9_\\s\\.]*";
	
	validateType type;

	public OwnPatternValidator(validateType type) {
		super( type.toString(),Pattern.CASE_INSENSITIVE);

		this.type = type;

	}

	/**
	 * @see AbstractValidator#resourceKey()
	 */
	@Override
	protected String resourceKey() {
		String resources = "validate.";
		switch (type) {
		case ALPHA_NUMERIC:
			resources += "ALPHA_NUMERIC";
			break;
		case NUMERIC:
			resources += "NUMERIC";
			break;
		case EMAIL:
			resources += "EMAIL";
			break;
		case ALPHABETIC:
			resources += "ALPHABETIC";
			break;
		case PASSWORD:
			resources += "PASSWORD";
			break;

		}
		return resources;
//		return super.resourceKey();
	}
}
